import BaseModel from "../../../cfw/mvc/BaseModel";
import ModelManager from "../../../cfw/mvc/ModelManager";
import CristmasLightModel from "./CristmasLightModel";
import CristmasToyModel from "./CristmasToyModel";
import ModuleManager from "../../../cfw/module/ModuleManager";
import User from "../../db/User";


export default class CristmasTreeManager extends BaseModel {


    private static ins: CristmasTreeManager;

    static instance() {
        if (!this.ins) {
            this.ins = new CristmasTreeManager()
        }
        return this.ins;
    }

    protected lightMgr: ModelManager<CristmasLightModel> = new ModelManager()
    protected toyMgr: ModelManager<CristmasToyModel> = new ModelManager()

    constructor() {
        super();

        this.lightMgr.initWithData(ModuleManager.dataManager.get(CristmasLightModel.CLASS_NAME), CristmasLightModel)
        cc.log('data888888888888888888888888 size ',this.lightMgr.getData().size())
        this.toyMgr.initWithData(ModuleManager.dataManager.get(CristmasToyModel.CLASS_NAME), CristmasToyModel)
    }

    getLight(id:number){
        return this.lightMgr.getByID(id)
    }

    getToy(id:number){
        return this.toyMgr.getByID(id)
    }

    getLightList() {
        return this.lightMgr.getList()
    }

    getToyList() {
        return this.toyMgr.getList()
    }


    getToyTypeData(index){
        return User.instance().getToyTypeData(index);
    }

    getLightID(){
        return User.instance().getLightID();
    }




}
